package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.entity.PageResult;
import com.itheima.pojo.CheckItem;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CheckItemDao {
    //插入检查项信息
    @Insert("insert into t_checkitem values (null,#{code},#{name},#{sex},#{age},#{price},#{type},#{remark},#{attention})")
    public void add(CheckItem checkItem);

    //查询所有的检查信息
    public List<CheckItem> selectByCondition(String queryString);

    //根据id删除检查项信息
    @Delete("delete from t_checkitem where id=#{id}")
    void deleteById(Integer id);

    //判断检查项是否与检查组关联
    @Select("select count(*) from t_checkgroup_checkitem where checkitem_id =#{checkitem_id}")
    Long findCountByCheckItemId(Integer CheckItemId);

    //感觉id查询检查项信息
    @Select("select * from t_checkitem where id = #{id}")
    CheckItem findById(Integer id);

    //编辑检查项信息
    void edit(CheckItem checkItem);

    //查询所有的检查项信息
    @Select("select * from t_checkitem")
    List<CheckItem> findAll();

    //多表查询，根据检查组id查询包含的检查项
    @Select("select * from t_checkitem where id in (select checkitem_id from t_checkgroup_checkitem where checkgroup_id = #{id})")
    List<CheckItem> findCheckItemById(Integer id);
}